package cn.itcast.dao;

import cn.itcast.pojo.Order;
import cn.itcast.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrderDao {


    @Select("select * from t_ordersetting where orderDate=#{orderDate}")
    OrderSetting findByDate(String orderDate);

    @Select("select * from t_order where idCard=#{idCard} and setmealId=#{setmealId} and orderDate=#{orderDate}")
    Object ExistOrNot(String idCard, Integer setmealId, String orderDate);

//    @Insert("insert   into   t_order   values(id,memberId,orderDate," +
//            "orderType,orderStatus,setmealId,arrival,phoneNumber,name,idCard,birthday," +
//            "sex,married,addressId,payStatus) ")
    @Insert("insert   into   t_order   values(#{id},#{memberId},#{orderDate}," +
            "#{orderType},#{orderStatus},#{setmealId},#{arrival},#{phoneNumber},#{name},#{idCard},#{birthday}," +
            "#{sex},#{married},#{addressId},#{payStatus}) ")
    void add(Order order);

    @Select("select * from t_order where id = #{id} ")
    Order findById(String id);


    @Select("select * from t_order where memberId = #{id}")
    List<Order> findUserAll(Integer id);



    @Update("UPDATE t_order SET payStatus=#{status} where id = #{orderId}")
    void updatePayStatus(String orderId,short status);
}
